<?php

namespace app\yj\controller;

use think\App;
use think\Controller;
use think\Request;

class ttController extends Controller
{
    protected $conDatas;

    public function __construct(App $app = null)
    {
        parent::__construct($app);
        $this->conDatas = [
            ['name' => 'name', 'type' => 'string', 'isnull' => 1],
            ['name' => 'phone', 'type' => 'int', 'isnull' => 1],
        ];
    }

    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index(Request $request)
    {
        //
        $datas = $request->post();
        $postdata = $this->checkData($datas);
        var_dump($postdata);
    }


    public function checkData($datas = [])
    {
        $retdata = [];
        foreach ($this->conDatas as $cv) {
            if (key_exists($cv['name'], $datas)) {
                $retdata[$cv['name']] = $datas[$cv['name']];
            }
        }

        return $retdata;
    }

}
